package cn.lf.controller;

import cn.lf.dto.api.product.IndexProductInfoRepDTO;
import cn.lf.dto.api.product.IndexProductInfoReqDTO;
import cn.lf.dto.api.product.ShopProductInfoRepDTO;
import cn.lf.service.ApiProductService;
import cn.lf.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
@Api(tags = "商品信息相关接口")
public class ApiProductController {

    @Autowired
    private ApiProductService productService;

    @GetMapping("/getIndexProductInfo")
    @ApiOperation("获取首页商品信息")
    public ResponseModel<IPage<IndexProductInfoRepDTO>> getIndexProductInfo(IndexProductInfoReqDTO params){

        IPage<IndexProductInfoRepDTO> result = productService.getIndexProductInfo(params);

        return ResponseModel.buildSuccessResult(result);
    }

    @GetMapping("/getShopProductInfoList")
    @ApiOperation("获取店铺商品信息")
    public ResponseModel<List<ShopProductInfoRepDTO>> getShopProductInfoList(@RequestParam String shopId){

        List<ShopProductInfoRepDTO> list = productService.getShopProductInfoList(shopId);

        return ResponseModel.buildSuccessResult(list);
    }
}
